package sk.uniba.fmph.asdf.test;

import sk.uniba.fmph.asdf.SerializableEntity;

/**
 * Trieda obsahujuca udaje o konkretnej peciatke.
 *
 * @author Matej
 * @author tim
 * @author ivor
 * @serial
 */
public class Stamp extends SerializableEntity {

	private static final long serialVersionUID = -8983607216311787304L;

	/**
	 * Identifikator peciatky.
	 * @serial
	 */
	private int id;

    /**
     * Typ peciatky.
     * @serial
     */
	private StampType type;

    private RelativePoint position;

    @Override
    public void validateState() {
        //type.validateState();
    	validateId(id);
        validateCoord(position.x);
        validateCoord(position.y);
    }

    /**
     * Metoda overi spravnost koordinatu
     * @param coord koordinat
     */
    private void validateCoord(final float coord) {
        // TODO: naozaj to chceme takto validovat? -tim
        if (coord < 0) {
            throw new IllegalArgumentException(String.valueOf(coord));
        }
    }

	public Stamp(int id, float posX, float posY, StampType type) {
		this.id = id;
		this.type = type;
		this.position = new RelativePoint(posX, posY);
	}

	public Stamp(float posX, float posY, StampType type) {
		this(-1, posX, posY, type);
	}

	public RelativePoint getPosition() {
		return position;
	}

	public void setPosX(float posX) {
		this.position.x = posX;
	}

	public void setPosY(float posY) {
		this.position.y = posY;
	}

	public StampType getStampType() {
		return type;
	}
}
